<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <script src="./js/jquery-3.1.0.min.js"></script>
    <script src="./js/flexible.debug.js"></script>
    <script src="./js/flexible_css.debug.js"></script>
    <link rel="stylesheet" href="./css/login.css">
    <title>登录</title>
</head>
<body>
    <div class="container">
        <input type="text" name="username" id="username" placeholder="用户名" />
        <input type="number" name="mobile" id="mobile" placeholder="手机号" />
        <input type="password" name="passwod" id="passwod" placeholder="密码" />
        <input type="button" value="确认登录" id="passwod" onclick="login()"/>
    </div>
</body>
<script>
    var login = function(){
        var username = $('#username').val();
        var password = $('#password').val();
        var mobile = $('#mobile').val();
        if(!(username && password && mobile)){
            alert('请完善后再登录');
        }
        if((/^[1][3,4,5,7,8][0-9]{9}$/).test(mobile)){
            console.log('手机号格式不正确');
        }
        $.ajax({
            url: 'https://dingwei.famishare.me/login.php',
            method: 'POST',
            data: {
                username: username,
                password: password,
                action: 'login'
            },
            // contentType: 'application/json',
            success: function(res){
                location.href = 'index.html';
            }
        });
        location.href = 'index.html';
    }

</script>
</html>